SHELL=bash


# Very fast, low memory URL parser in C
#   http://github.com/nathanwiegand/urlparser
# currently using revision 10
URL_VERSION=11
ext/urlparser-$(URL_VERSION)/urlparser.o:
	mkdir -p ext; \
	pushd ext; \
	svn co -r$(URL_VERSION) http://svn.github.com/nathanwiegand/urlparser.git urlparser-$(URL_VERSION); \
	rm -f urlpaser; \
	ln -s urlparser-$(URL_VERSION) urlparser; \
	pushd urlparser; \
	$(CC) $(CFLAGS) -c urlparser.c; 
REALCLEAN_OBJS+=ext/urlparser-$(URL_VERSION) ext/urlparser
EXT+=ext/urlparser-$(URL_VERSION)/urlparser.o


# v8: Google's JavaScript interpreter.
#   http://code.google.com/p/v8/
# currently using revision 4439
ifeq ($(shell gcc -v 2>&1| tail -n 1 | grep " 4.4"|wc -l), 1)
  VERSIONFIX=export GCC_VERSION=44
else
  VERSIONFIX=echo ""
endif

V8_VERSION=4439
ext/v8-$(V8_VERSION)/libv8.a:
	mkdir -p ext; \
	pushd ext; \
	svn checkout -r$(V8_VERSION) http://v8.googlecode.com/svn/trunk/ v8-$(V8_VERSION); \
	rm -f v8; \
	ln -s v8-$(V8_VERSION) v8; \
	pushd v8; $(VERSIONFIX) && scons mode=release snapshot=on library=static; popd
EXT+=ext/v8-$(V8_VERSION)/libv8.a
REALCLEAN_OBJS+=ext/v8 ext/v8-$(V8_VERSION)

# libcurl
LIBCURL_VERSION=7.20.1
ext/libcurl: 
	mkdir -p ext; \
	pushd ext; \
	wget http://curl.haxx.se/download/curl-$(LIBCURL_VERSION).tar.gz;\
	tar xvzf curl-$(LIBCURL_VERSION).tar.gz; \
	rm -f libcurl; \
	ln -s curl-$(LIBCURL_VERSION) libcurl; 
EXT+=ext/libcurl
REALCLEAN_OBJS+=ext/libcurl ext/curl-$(LIBCURL_VERSION) ext/curl-$(LIBCURL_VERSION).tar.gz
